<template>
    <div class="add_body" ref="scroll_wrap">
        <order-item @cancleOrder="cancleOrder" v-for="(item , index) in dataList" :orderItem="item" :key="index">
        </order-item>
      <cancle-cause v-if="cancleCause" @confirm="confirm" @cancle="cancle" :cancleList="cancleCauseList"></cancle-cause>
    </div>
</template>

<script>
  import back from 'components/back'
  import {stop_slider} from 'assets/base/base'
  import addAddress from 'components/add_address'
  import {get_cookie} from 'assets/cookie/cookie'
  import {get_address_list} from 'api/address'
  import {get_cancle_cause,cancle_order} from 'api/order'
  import orderItem from 'components/orderItem'
  import cancleCause from 'components/cancleCause'
  export default {
    name: "",
    props:['title','dataList'],
    data(){
      return{
        orderType:'',
        cancleCause:false,
        cancleCauseList:[]
      }
    },
    created(){
      get_cancle_cause({}).then((res)=>{
        if(res.status===200&&res.data.resStatus===0) {
           this.cancleCauseList=res.data.data
          console.log( this.cancleCauseList)
        }else{
            alert(res.data.message)
        }
      })
    },
    activated(){
      this.cancleCause=false
    },
    mounted(){

    },
    computed:{

    },
    methods:{
      cancle(){
        this.cancleCause=false
      },
      cancleOrder(id){
          this.cancleOrderId=id
         this.cancleCause=true
      },
      confirm(cancleId){
        this.cancleCause=false
        cancle_order({
          orderId:this.cancleOrderId,
          token:get_cookie('key'),
          offwhy:cancleId
        }).then((res)=>{
          console.log(res)
          if(res.status===200&&res.data.resStatus===0) {
            this.$emit('cancle_get_order_list')
          }
        })
      }
    },
    components:{
      back,
      orderItem,
      cancleCause
    }
  }
</script>

<style scoped lang="scss">
  .add_body{
    width: 100%;
    max-width: 768px;
    padding-top: 21px;
    margin: 0 auto;
    >div:last-child{
      margin-bottom: 0;
    }
  }
</style>
